Daniel Weiand, Consultant medical microbiologist
Newcastle upon Tyne Hospitals NHS Foundation Trust
November 17, 2022
On the one hand…
Finishing a project is often the hardest part
Install Zotero
Then signpost your .bib, .csl, .docx., and .css files in your YAML 7 8
Don’t forget to e.g. load your packages and select appropriate knitr options
#Project setup
options(scipen = 1, digits = 3)
ggplot2::theme_set(ggplot2::theme_minimal())
#Package load
library(citr)
library(tidyverse)
library(here)
library(flextable)
library(AMR)
#knitr options
knitr::opts_chunk$set(dev='jpeg',
dpi = 300,
fig.path = 'figures/',
fig.width = 6,
fig.asp = 0.618,
fig.align = 'center',
out.width = "70%",
cache.path = 'cache/',
cache = FALSE) You can cite references listed in the .bib file, signposted in the YAML
Conventionally, citations need to be manually typed inside square brackets:
Instead, with {citr} you can simply click on the Addins button in RStudio
Click on insert citations
And use the free-text box to fuzzy search by author / date / title / journal & click insert citation
For example, the following code …
… can be used to cross-reference to the following figure
Figure 1 further explores the impact of temperature on ozone level.
Add a div with the id {#refs} at the location in your document where you’d like the bibliography to be generated.
Daniel Weiand, Consultant medical microbiologist
Newcastle upon Tyne Hospitals NHS Foundation Trust
Email: dweiand@nhs.net
NHS-R community blog: https://nhsrcommunity.com/author/daniel-weiand/
Twitter: @send2dan
The Better BibTeX (BBT) extension for Zotero makes it easier to manage bibliographic data using markdown
Search the Zotero style library for .csl files
Use MS Word to set the Style of e.g. headings in the reference-doc
.css files can be used for additional formatting (e.g. add double spacing to the final, rendered document)
See my recent blog posts for further information on some of the differences in YAML requirements between .qmd (Quarto) and .rmd (RMarkdown)
The {citr}package is not currently available on CRAN; install it through GitHub
the files referred to in the YAML should be located in the main project directory
Choosing link-citations: yes option will make your citations hyperlinks to the corresponding bibliography entries.